Field of the Invention
The present invention relates to a coding method and a decoding processing method, and in particular, relates to a technique for handling the recording of a RAW image of a moving image or a still image.
Description of the Related Art
In a conventional image capturing apparatus, raw image information (RAW image) captured by an imaging sensor is debayered (demosaiced), the debayered raw image information is converted to signals constituted by a luminance signal and a color difference signal, and so-called development processing such as denoising, optical distortion correction, and image optimization is performed on each signal. In general, the luminance signal and the color difference signal that have been subjected to the development processing are then compressed and coded, and recorded on a recording medium. On the other hand, there are image capturing apparatuses that are capable of recording a RAW image. Although the data amount that needs to be recorded is extremely large with a RAW image, there are advantages in that correction and deterioration of the original image are suppressed to a minimum and the RAW image can be edited after image capture, and thus experienced users with editing skills prefer to use RAW images. Also, in recent years, recording of RAW images has been applied to not only still images but also moving images. When recording a moving image as a RAW image, it is necessary to perform control for compressing the data amount to a desired code amount so as to record a moving image having a given time length on a predetermined recording medium.
However, if the code amount control and quantization control are not appropriately performed, a data amount that exceeds the transfer rate to the predetermined recording medium occurs, resulting in the data on the recording medium being corrupted. Also, even if the RAW data is written on the recording medium, if the bit rate guaranteed for real-time reproduction is exceeded, this data cannot be correctly reproduced by a reproduction device. In readiness for such cases, it is necessary to provide a mechanism that is able to reduce the data amount after coding. As a method for compressing RAW images, it is thought that a method, such as JPEG 2000, that involves breaking the data into sub-bands, which are frequency bands, using frequency transformation such as wavelet transformation, and compressing each sub-band, such that no block distortion occurs due to coding, rather than compressing the data by performing DCT in block units, is suitable. A configuration of an image capturing apparatus that can reduce the data amount after coding in JPEG 2000 is described in Japanese Patent Laid-Open No. 2004-297195, for example. In JPEG 2000, EBCOT (Embedded Block Coding with Optimized Truncation), which is embedded coding, is adopted in compression coding, and coding is performed in bit plane units per rectangular block in a screen, thus providing a mechanism that discards bit planes having a low importance after coding. Also, there is a mechanism that has a layer structure and discards layers having a low importance, and by using these techniques, the data amount can be reduced after coding.
However, because EBCOT has a heavy processing load and has an extremely large computation amount, it is difficult to apply EBCOT to all of the coding, and thus, in particular, EBCOT is not suitable for an embedded device that needs to perform real-time processing. Also, if a layer structure is adopted, overheads occur, and thus the layer structure is not always used.
The technique described in Japanese Patent Laid-Open No. 2004-297195 is such that the priorities are given to sub-bands, coded streams are configured in order, and if data exceeds a predetermined size, the subsequent data is truncated by inserting an end code, and, at the time of reproduction, decoding processing is performed with the data after the end code set to 0 data. There are problems in that this decoding processing needs a special decoder, and in particular, if a plurality of sub-bands are truncated, the truncated sub-bands cannot be comprehended without retrieving the end code from the data.